package com.his.server.utils.dao;

import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.sql.*;
import java.util.Calendar;

public class DaoUtil {
	
	private static StatementAdapter.Statement defaultStatement = null;

    private DaoUtil()
    {
    }

    protected static StatementAdapter.Statement getStatement() {
    	 defaultStatement = new StatementAdapterImpl();
    	 return defaultStatement;
    }

	public static void setBigDecimal(PreparedStatement stmt, int idx,
			BigDecimal val) throws SQLException {
		getStatement().setBigDecimal(stmt, idx, "", val);
	}
	
    public static void setAsciiStream(PreparedStatement stmt, int idx, InputStream val, int length)
            throws SQLException
        {
            getStatement().setAsciiStream(stmt, idx, "", val, length);
        }
    
    public static void setBinaryStream(PreparedStatement stmt, int idx, InputStream val, int length)
            throws SQLException
        {
            getStatement().setBinaryStream(stmt, idx, "", val, length);
        }
    
    public static void setBlob(PreparedStatement stmt, int idx, Blob val)
            throws SQLException
        {
            getStatement().setBlob(stmt, idx, "", val);
        }
    
    public static void setClob(PreparedStatement stmt, int idx, Clob val)
            throws SQLException
        {
            getStatement().setClob(stmt, idx, "", val);
        }
    
    public static void setBytes(PreparedStatement stmt, int idx, byte val[])
            throws SQLException
        {
            getStatement().setBytes(stmt, idx, "", val);
        }
    
    public static void setCharacterStream(PreparedStatement stmt, int idx, Reader val, int length)
            throws SQLException
        {
            getStatement().setCharacterStream(stmt, idx, "", val, length);
        }
    
    public static void setDate(PreparedStatement stmt, int idx, java.util.Date val)
            throws SQLException
        {
            getStatement().setDate(stmt, idx, "", val != null ? new Date(val.getTime()) : null);
        }
    
    public static void setDate(PreparedStatement stmt, int idx, java.util.Date val, Calendar cal)
            throws SQLException
        {
            getStatement().setDate(stmt, idx, "", val != null ? new Date(val.getTime()) : null, cal);
        }
    
    public static void setTime(PreparedStatement stmt, int idx, Time val)
            throws SQLException
        {
            getStatement().setTime(stmt, idx, "", val);
        }
    
    public static void setTime(PreparedStatement stmt, int idx, Time val, Calendar cal)
            throws SQLException
        {
            getStatement().setTime(stmt, idx, "", val, cal);
        }
    
    public static void setTimestamp(PreparedStatement stmt, int idx, Timestamp val)
            throws SQLException
        {
            getStatement().setTimestamp(stmt, idx, "", val);
        }
    
    public static void setTimestamp(PreparedStatement stmt, int idx, java.util.Date val)
            throws SQLException
        {
            getStatement().setTimestamp(stmt, idx, "", val != null ? new Timestamp(val.getTime()) : null);
        }
    
    public static void setTimestamp(PreparedStatement stmt, int idx, Timestamp val, Calendar cal)
            throws SQLException
        {
            getStatement().setTimestamp(stmt, idx, "", val, cal);
        }
    
    public static void setTimestamp(PreparedStatement stmt, int idx, java.util.Date val, Calendar cal)
            throws SQLException
        {
            getStatement().setTimestamp(stmt, idx, "", val != null ? new Timestamp(val.getTime()) : null, cal);
        }
    
    public static void setInt(PreparedStatement stmt, int idx, Integer val)
            throws SQLException
        {
            getStatement().setInteger(stmt, idx, "", val);
        }
    
    public static void setBoolean(PreparedStatement stmt, int idx, Boolean val)
            throws SQLException
        {
            getStatement().setBoolean(stmt, idx, "", val);
        }
    
    public static void setLong(PreparedStatement stmt, int idx, Long val)
            throws SQLException
        {
            getStatement().setLong(stmt, idx, "", val);
        }
    
    public static void setShort(PreparedStatement stmt, int idx, Short val)
            throws SQLException
        {
            getStatement().setShort(stmt, idx, "", val);
        }
    
    public static void setFloat(PreparedStatement stmt, int idx, Float val)
            throws SQLException
        {
            getStatement().setFloat(stmt, idx, "", val);
        }
    
    public static void setDouble(PreparedStatement stmt, int idx, Double val)
            throws SQLException
        {
            getStatement().setDouble(stmt, idx, "", val);
        }
    
    public static void setByte(PreparedStatement stmt, int idx, Byte val)
            throws SQLException
        {
            getStatement().setByte(stmt, idx, "", val);
        }
    
    public static void setString(PreparedStatement stmt, int idx, String val)
            throws SQLException
        {
            getStatement().setString(stmt, idx, "", val);
        }
    
    public static Boolean getBoolean(ResultSet rs, int idx)
            throws SQLException
        {
            return getStatement().getBoolean(rs, idx, "");
        }

        public static Integer getInteger(ResultSet rs, int idx)
            throws SQLException
        {
            return getStatement().getInteger(rs, idx, "");
        }

        public static Long getLong(ResultSet rs, int idx)
            throws SQLException
        {
            return getStatement().getLong(rs, idx, "");
        }

        public static Short getShort(ResultSet rs, int idx)
            throws SQLException
        {
            return getStatement().getShort(rs, idx, "");
        }

        public static Float getFloat(ResultSet rs, int idx)
            throws SQLException
        {
            return getStatement().getFloat(rs, idx, "");
        }

        public static Double getDouble(ResultSet rs, int idx)
            throws SQLException
        {
            return getStatement().getDouble(rs, idx, "");
        }

        public static Byte getByte(ResultSet rs, int idx)
            throws SQLException
        {
            return getStatement().getByte(rs, idx, "");
        }
        
        public static String getString(ResultSet rs, int idx, String dbtype)
                throws SQLException
            {
                String ret = getStatement().getString(rs, idx, dbtype);

                return ret;
            }
}